<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TopicBbs extends Model
{
    protected $table = 'topics';

    public function user()
    {
        return $this->belongsTo('App\Models\User', 'user_id', 'id');
    }

    public function sections()

    {
        return $this->belongsTo('App\Models\Section', 'section', 'id');
    }

    public function tags()
    {
        return $this->belongsToMany('App\Models\Tag', 'topic_tag', 'topic_id', 'tag_id');
    }

    public function replies()
    {
        return $this->hasMany('App\Models\Reply', 'topic_id', 'id')->with('user');
    }

    public function vote()
    {
        return $this->hasMany('App\Models\Vote', 'topic_id', 'id');
    }

    public function images()
    {
        return $this->hasMany('App\Models\Image', 'image_id', 'id');
    }

    public function profile(){
        return $this->hasOne('App\Models\Profile','user_id','user_id');
    }

}
